﻿using System;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Threading;

namespace ScreenShot.pictureManager
{
   
    /// <summary>
    /// Class to create screen captures.
    /// </summary>
    class pictureManager
    {
        private Boolean withForm = true;

        public Boolean WithForm
        {
            get { return withForm; }
            set { withForm = value; }
        }
        /// <summary>
        /// This method return screen image.
        /// </summary>
        /// <returns>screen image</returns>
        public Image takeScreenshot()
        {
            if (!withForm)
                Thread.Sleep(200);
            Bitmap screenBitmap=  new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                            Screen.PrimaryScreen.Bounds.Height, 
                                            PixelFormat.Format32bppArgb);
        Graphics gfxScreenshot = Graphics.FromImage(screenBitmap);
        gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);

            return screenBitmap;
            
        }
 
    }
}
